home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / RCS / values.h,v < prev    next >
Encoding:
Text File  |  1992-12-04  |  4.4 KB  |  140 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     92.12.03.16.27.41;  author jhh;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     92.12.03.16.27.24;  author jhh;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @sun value for MAXDOUBLE rejected by assembler (probably printf in compiler)
  27. I changed it to the mips value
  28. @
  29. text
  30. @
  31. #ifndef VALUES_H
  32. #define VALUES_H
  33.  
  34. /* These values work with any binary representation of integers
  35.  * where the high-order bit contains the sign. */
  36.  
  37. /* a number used normally for size of a shift */
  38. #define BITSPERBYTE    8
  39. #define BITS(type)    (BITSPERBYTE * (int)sizeof(type))
  40.  
  41. /* short, regular and long ints with only the high-order bit turned on */
  42. #define HIBITS    ((short)(1 << BITS(short) - 1))
  43. #define HIBITI    (1 << BITS(int) - 1)
  44. #define HIBITL    (1L << BITS(long) - 1)
  45.  
  46. /* largest short, regular and long int */
  47. #define MAXSHORT    ((short)~HIBITS)
  48. #define MAXINT    (~HIBITI)
  49. #define MAXLONG    (~HIBITL)
  50.  
  51. /* various values that describe the binary floating-point representation
  52.  * _EXPBASE    - the exponent base
  53.  * DMAXEXP     - the maximum exponent of a double (as returned by frexp())
  54.  * FMAXEXP     - the maximum exponent of a float  (as returned by frexp())
  55.  * DMINEXP     - the minimum exponent of a double (as returned by frexp())
  56.  * FMINEXP     - the minimum exponent of a float  (as returned by frexp())
  57.  * MAXDOUBLE    - the largest double
  58.             ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
  59.  * MAXFLOAT    - the largest float
  60.             ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
  61.  * MINDOUBLE    - the smallest double (_EXPBASE ** (DMINEXP - 1))
  62.  * MINFLOAT    - the smallest float (_EXPBASE ** (FMINEXP - 1))
  63.  * DSIGNIF    - the number of significant bits in a double
  64.  * FSIGNIF    - the number of significant bits in a float
  65.  * DMAXPOWTWO    - the largest power of two exactly representable as a double
  66.  * FMAXPOWTWO    - the largest power of two exactly representable as a float
  67.  * _IEEE    - 1 if IEEE standard representation is used
  68.  * _DEXPLEN    - the number of bits for the exponent of a double
  69.  * _FEXPLEN    - the number of bits for the exponent of a float
  70.  * _HIDDENBIT    - 1 if high-significance bit of mantissa is implicit
  71.  * LN_MAXDOUBLE    - the natural log of the largest double  -- log(MAXDOUBLE)
  72.  * LN_MINDOUBLE    - the natural log of the smallest double -- log(MINDOUBLE)
  73.  * LN_MAXFLOAT    - the natural log of the largest float  
  74.  * LN_MINFLOAT    - the natural log of the smallest float
  75.  */
  76. #if sun
  77. #define MAXDOUBLE       1.79769313486231470e+308
  78. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  79. #define MINDOUBLE    4.94065645841246544e-324
  80. #define MINFLOAT    ((float)1.40129846432481707e-45)
  81. #define    _IEEE        1
  82. #define _DEXPLEN    11
  83. #define _HIDDENBIT    1
  84. #define DMINEXP    (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  85. #define FMINEXP    (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  86. #define LN_MAXFLOAT    8.8722839052068e+01
  87. #define LN_MINFLOAT    -1.03278929903432e+02
  88. #endif
  89.  
  90. #if mips
  91. #define MAXDOUBLE       1.79769313486231470e+308
  92. #define MAXFLOAT        ((float)3.40282346638528860e+38)
  93. #define MINDOUBLE       4.94065645841246544e-324
  94. #define MINFLOAT        ((float)1.40129846432481707e-45)
  95. #define _IEEE           1
  96. #define _DEXPLEN        11
  97. #define _HIDDENBIT      1
  98. #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  99. #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  100. #define LN_MAXFLOAT     (M_LN2 * FMAXEXP)
  101. #define LN_MINFLOAT     (M_LN2 * (FMINEXP - 1))
  102. #endif
  103.  
  104. #define _EXPBASE    (1 << _LENBASE)
  105. #define _FEXPLEN    8
  106. #define DSIGNIF    (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
  107. #define FSIGNIF    (BITS(float)  - _FEXPLEN + _HIDDENBIT - 1)
  108. #define DMAXPOWTWO    ((double)(1L << BITS(long) - 2) * \
  109.                 (1L << DSIGNIF - BITS(long) + 1))
  110. #define FMAXPOWTWO    ((float)(1L << FSIGNIF - 1))
  111. #define DMAXEXP    ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  112. #define FMAXEXP    ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  113. #define LN_MAXDOUBLE    (M_LN2 * DMAXEXP)
  114. #define LN_MINDOUBLE    (M_LN2 * (DMINEXP - 1))
  115.  
  116. #define H_PREC    (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
  117. #define X_EPS    (1.0/H_PREC)
  118. #define X_PLOSS    ((double)(long)(M_PI * H_PREC))
  119. #define X_TLOSS    (M_PI * DMAXPOWTWO)
  120. #define M_LN2    0.69314718055994530942
  121. #define M_PI    3.14159265358979323846
  122. #define M_SQRT2    1.41421356237309504880
  123. #define MAXBEXP    DMAXEXP /* for backward compatibility */
  124. #define MINBEXP    DMINEXP /* for backward compatibility */
  125. #define MAXPOWTWO    DMAXPOWTWO /* for backward compatibility */
  126.  
  127. #endif /* VALUES_H */
  128. @
  129.  
  130.  
  131. 1.1
  132. log
  133. @Initial revision
  134. @
  135. text
  136. @d48 1
  137. a48 1
  138. #define MAXDOUBLE    1.797693134862315708e+308
  139. @
  140.